package com.disease.api.service.service;

import com.disease.api.service.entity.BaseUser;
import com.disease.api.service.entity.eumns.RoleEnum;
import com.disease.api.service.model.response.EmrDeathInfoResponse;

public class PermissionAccessService {

    public static void setPermission(BaseUser user, EmrDeathInfoResponse deathInfoResponse) {
        isDownLoadPermission(user, deathInfoResponse);
        isPrintFirstFormPermission(user, deathInfoResponse);
    }

    //公卫科和管理员具备下载第一联权限
    private static void isDownLoadPermission(BaseUser user, EmrDeathInfoResponse deathInfoResponse) {
        if (!user.getRole().equals(RoleEnum.DOCTOR.getRoleId())) {
            deathInfoResponse.setDownload(true);
        }
    }

    //公卫科和管理员具备打印第一联权限
    private static void isPrintFirstFormPermission(BaseUser user, EmrDeathInfoResponse deathInfoResponse) {
        if (!user.getRole().equals(RoleEnum.DOCTOR.getRoleId())) {
            deathInfoResponse.setPrintFirstForm(true);
        }
    }

}
